<!-- 用户中心 -->
<template>
  <div>
    <wbc-nav></wbc-nav>

    <div class="container">

<!--      &lt;!&ndash; 搜索框 &ndash;&gt;-->
<!--      <div  class="search-container">-->

<!--      <el-input-->
<!--        v-model="searchText"-->
<!--        placeholder="请输入文章标题进行搜索"-->
<!--        clearable-->
<!--        @clear="handleSearch"-->
<!--        @keyup.enter.native="handleSearch"-->
<!--        style="margin-bottom: 20px;"-->
<!--      ></el-input>-->
<!--      &lt;!&ndash; 搜索按钮 &ndash;&gt;-->
<!--      <el-button type="primary" @click="handleSearch">搜索</el-button>-->
<!--      </div>-->
      <div class="data-list">

        <ul>
          <li v-for="article in collects" :key="article.id" @click="goToArticle(article.id)" style="cursor: pointer;">{{ article.title }}</li>
        </ul>
      </div>

      <!-- 分页组件 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="pageSize"
        :total="totalItems"
        layout="total, sizes, prev, pager, next, jumper"
      ></el-pagination>

    </div>
  </div>
</template>

<script>
import header from '../components/header.vue'
import {getUserCollects} from '../api/collect.js'//获取用户信息，保存用户信息
import store from '../store'
export default {
  name: 'UserInfo',
  data() { //选项 / 数据
    return {
      id: '',
      collects: [],
      currentPage: 1, // 当前页码
      pageSize: 10, // 每页显示条数
      searchText: '', // 搜索关键字
    }
  },
  methods: { //事件处理器
    // 当前页码改变时的回调函数
    handleCurrentChange(newPage) {
      this.currentPage = newPage;
    },
    // 每页显示条数改变时的回调函数
    handleSizeChange(newSize) {
      this.pageSize = newSize;
      this.currentPage = 1; // 改变每页条数后回到第一页
    },
    getCollects() {
      getUserCollects(this.searchText,this.currentPage,this.pageSize).then((re)=>{
          this.collects = re.rows
      })
    },
    goToArticle(articleId) {
      // 点击跳转到文章详情页面
      // 假设文章详情页面的路由为 '/article/:id'
      this.$router.push({ path: '/DetailArticle', query: { aid: articleId }});
    }
    },

  components: { //定义组件
    'wbc-nav':header,
  },
  watch: {
    // 如果路由有变化，会再次执行该方法
    '$route':'routeChange'
  },
  created() { //生命周期函数
      this.getCollects();
  }
}
</script>

<style>
.search-container {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}
.userInfoBox .avatarlist{
  position: relative;
}

.avatar-uploader {
  display: inline-block;
  vertical-align: top;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  width: 120px;
  height: 120px;
}
.avatar-uploader .el-upload:hover {
  border-color: #20a0ff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 120px;
  height: 120px;
  line-height: 120px;
  text-align: center;
  position: absolute;
  top:0;
  left:0;
}
.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
}


/* 样式可以根据需要进行调整 */
ul {
  list-style-type: none; /* 去除列表样式 */
  padding: 0;
}

li {
  margin-bottom: 10px; /* 列表项间距 */
}

li:hover {
  color: blue; /* 鼠标悬停时改变颜色 */
}
.gotoEdit{
  font-size: 15px;
  float:right;
  cursor: pointer;
  color:#999;
}
.gotoEdit:hover {
  color:#333;
}
/*个人设置*/
.userInfoBox .leftTitle{
  display: inline-block;
  width:100px;
  padding: 10px 0;
}
.userInfoBox .rightInner{
  display: inline-block;
  max-width: calc(100% - 140px);
  vertical-align: top;
}
.userInfoBox li{
  padding:20px;
  border-bottom: 1px solid #ddd;
}
.userInfoBox li:last-child{
  border-bottom: 1px solid transparent;
}
.userInfoBox  .el-input,.userInfoBox  .el-textarea{
  max-width:300px;
  min-width: 100px;
}

.userInfoBox .el-input__inner{
  border-radius: 4px;
}
.userInfoBox  .el-textarea{
  vertical-align: top;
}
.saveInfobtn{
  margin: 20px 0;
  text-align: center;
}
.saveInfobtn a{
  color:#fff;
  padding:6px 20px;
  margin:5px 10px;
  border-radius: 5px;
  font-size: 14px;
}
.userInfoBox .fa-asterisk{
  color: #DF2050;
}
</style>

